// ImageRendering.h

#pragma once

using namespace System;

#pragma managed

namespace CPPClassLibrary {


	public ref class ImageFiltering
	{
	public:
	
		ImageFiltering() 
		{			
			CheckInit();
		}

		static void CheckInit(void)
		{
			if (!Initialized)
			{				
				Initialize();				
				Initialized = true;
			}
		}

		void DoFilterRGB(int pixelSize, int *pkernel, unsigned char *src, unsigned char *dst, 
				   int startX, int startY, int stopX, int stopY, int size, int srcStride, int divisor, 
				   bool dynamicDivisorForEdges, int threshold, int srcOffset, int dstOffset)
		{
			DoFilterImageRGB(pixelSize, pkernel, src, dst, startX, startY, stopX, stopY, size, srcStride, divisor, dynamicDivisorForEdges, threshold, srcOffset, dstOffset);
		}

		void DoFilterGrayscale(int pixelSize, int *pkernel, unsigned char *src, unsigned char *dst, 
				   int startX, int startY, int stopX, int stopY, int size, int srcStride, int divisor, 
				   bool dynamicDivisorForEdges, int threshold, int srcOffset, int dstOffset)
		{
			DoFilterImageGrayscale(pixelSize, pkernel, src, dst, startX, startY, stopX, stopY, size, srcStride, divisor, dynamicDivisorForEdges, threshold, srcOffset, dstOffset);
		}

		void DoResizeBicubic(unsigned char *src, unsigned char *dst, double xFactor, double yFactor, 
					int height, int width, int newHeight, int newWidth, int srcStride, int dstOffset)
		{
			ResizeBicubic(src, dst, xFactor, yFactor, height, width, newHeight, newWidth, srcStride, dstOffset);
		}

		void DoResizeBilinear(unsigned char *src, unsigned char *dst, double xFactor, double yFactor, 
					int height, int width, int newHeight, int newWidth, int srcStride, int dstOffset, int pixelSize)
		{
			ResizeBilinear(src, dst, xFactor, yFactor, height, width, newHeight, newWidth, srcStride, dstOffset, pixelSize);
		}

		void DoResizeNearestNeighbor(unsigned char *baseSrc, unsigned char *baseDst, double xFactor, double yFactor, 
					int height, int width, int newHeight, int newWidth, int pixelSize, int srcStride, int dstStride)
		{
			ResizeNearestNeighbor3(baseSrc, baseDst, xFactor, yFactor, height, width, newHeight, newWidth, pixelSize, srcStride, dstStride);
		}

		void DoFilterHSLLinear(int pixelSize, unsigned char *ptr, int startX, int startY, int stopX, int stopY, int offset,
				   double inLuminanceMin, double inLuminanceMax, double outLuminanceMin, double outLuminanceMax,
				   double inSaturationMin, double inSaturationMax, double outSaturationMin, double outSaturationMax)
		{
			FilterHSLLinear(pixelSize, ptr, startX, startY, stopX, stopY, offset,
				   inLuminanceMin, inLuminanceMax, outLuminanceMin, outLuminanceMax,
				   inSaturationMin, inSaturationMax, outSaturationMin, outSaturationMax);
		}

		static void DoCalcRGBToHSL(unsigned char red, unsigned char green, unsigned char blue, int *pHue, double *pSaturation, double *pLuminance)
		{
			CalcRGBToHSL(red, green, blue, pHue, pSaturation, pLuminance);
		}
			
		static void DoRGBToHSL(unsigned char red, unsigned char green, unsigned char blue, int *pHue, double *pSaturation, double *pLuminance)
		{			    
			RGBToHSL(red, green, blue, pHue, pSaturation, pLuminance);
		}		

		static void DoCalcRGBFromHSL(int hueIn, double luminance, double saturation, unsigned char *red, unsigned char *green, unsigned char *blue)
		{
			CalcRGBFromHSL(hueIn, luminance, saturation, red, green, blue);
		}

		static void DoSobelEdge( unsigned char *src, unsigned char *dst, unsigned char *dst2, int dstOffset, int srcOffset, int dstStride, int srcStride, int startX, int startY, int stopX, int stopY, bool scaleIntensity)
		{
			SobelEdge(src, dst, dst2, dstOffset, srcOffset, dstStride, srcStride, startX, startY, stopX, stopY, scaleIntensity);		
		}
	};
}
